{
  "properties" : { },
  "id" : "095ed956e25d4a2d9d1800d3147da507",
  "script" : null,
  "groupId" : "14f1a21ced0a4e9589c95c58b3b5bb48",
  "name" : "根据组织机构获取设备数量",
  "createTime" : 1727070965583,
  "updateTime" : 1726304314861,
  "lock" : "1",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "deviceCount",
  "method" : "GET",
  "parameters" : [ {
    "name" : "deptId",
    "value" : "1123598813738675201",
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  } ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"status\": 200,\n    \"message\": \"success\",\n    \"data\": {\n        \"deptName\": \"\",\n        \"regionCode\": \"\",\n        \"deptId\": \"\",\n        \"count\": 0,\n        \"id\": \"\"\n    }\n}",
  "description" : "",
  "requestBodyDefinition" : {
    "name" : "",
    "value" : { },
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  },
  "responseBodyDefinition" : {
    "name" : "",
    "value" : { },
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  }
}
================================
import org.springblade.common.cache.RegionCache;
import org.springblade.modules.system.entity.Region;
import org.springblade.common.cache.DeptCache;

sql1 = """

    SELECT ndmp_map.id, ndmp_map.dept_id, region_code, count(*) count
    from ndmp_map, ndmp_device
    WHERE ndmp_map.dept_id = ndmp_device.DCC_ID
    <if test="deptId != null and deptId != ''">
            and ndmp_map.dept_id = #{deptId}
    </if>

"""

sql2 = """
    SELECT ndmp_map.id, ndmp_map.dept_id, region_code, count(*) count
    from ndmp_map, ndmp_device
    WHERE ndmp_map.dept_id = ndmp_device.DCC_ID
    and region_code in(SELECT code FROM blade_region WHERE FIND_IN_SET((SELECT region_code FROM ndmp_map WHERE
    dept_id = #{deptId}),ancestors)>0) and ndmp_map.dept_id = #{deptId}

"""

obj1 = db.selectOne(sql1)
obj2 = db.selectOne(sql2)
obj1.count = obj1.count + obj2.count
mapVO = new HashMap();
Region region = RegionCache.getByCode(obj1.regionCode);
if (region != null) {
    mapVO.regionName = region.name;
    mapVO.provinceCode = region.provinceCode;
    mapVO.provinceName = region.provinceName;
}
mapVO.deptName = DeptCache.getById(obj1.deptId);
mapVO.id = obj1.id;
mapVO.deptId = obj1.deptId;
mapVO.regionCode = obj1.regionCode;
mapVO.count = obj1.count::int;

return mapVO